
#include "bsp_led.h"

/*****************************************
光电发光管,光电接收管 IO 初始化
*****************************************/
void BSP_leds_init(void)
{
	stc_gpio_cfg_t stcGpioCfg;  
    ///< 打开GPIO外设时钟门控
    Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); 
    
    ///< 端口方向配置->输出(其它参数与以上（输入）配置参数一致)
    stcGpioCfg.enDir = GpioDirOut;
    ///< 端口上下拉配置->上拉
    stcGpioCfg.enPu = GpioPuEnable;
    stcGpioCfg.enPd = GpioPdDisable;
    
    /*接收leds 阳极(octrl IO)初始化*/
    Gpio_Init(OCTRL_PORT, OCTRL_PIN, &stcGpioCfg);
    Gpio_ClrIO(OCTRL_PORT, OCTRL_PIN); 

	/*发射leds 阳极初始化*/
	Gpio_Init(LEDs_Left_Port, LEDs_Left_Pin, &stcGpioCfg);
	Gpio_ClrIO(LEDs_Left_Port, LEDs_Left_Pin); 
	
	Gpio_Init(LEDs_Right_Port, LEDs_Right_Pin, &stcGpioCfg);
	Gpio_ClrIO(LEDs_Right_Port, LEDs_Right_Pin); 


#if 0
	///< 端口上下拉配置->下拉
	stcGpioCfg.enPu = GpioPuDisable;
	stcGpioCfg.enPd = GpioPdEnable;
	   
	Gpio_Init(LED_Q1_PORT, LED_Q1_PIN, &stcGpioCfg);
	Gpio_ClrIO(LED_Q1_PORT, LED_Q1_PIN);  

	Gpio_Init(LED_Q2_PORT, LED_Q2_PIN, &stcGpioCfg);
	Gpio_ClrIO(LED_Q2_PORT, LED_Q2_PIN);  
	
	Gpio_Init(LED_Q3_PORT, LED_Q3_PIN, &stcGpioCfg);
	Gpio_ClrIO(LED_Q3_PORT, LED_Q3_PIN);  

#endif

	/*发射leds 阴极初始化*/	
	Gpio_Init(LEDs_D1_Port, LEDs_D1_Pin, &stcGpioCfg);
	Gpio_SetIO(LEDs_D1_Port, LEDs_D1_Pin); 
		
	Gpio_Init(LEDs_D2_Port, LEDs_D2_Pin, &stcGpioCfg);
	Gpio_SetIO(LEDs_D2_Port, LEDs_D2_Pin); 

	Gpio_Init(LEDs_D3_Port, LEDs_D3_Pin, &stcGpioCfg);
	Gpio_SetIO(LEDs_D3_Port, LEDs_D3_Pin); 
	
	Gpio_Init(LEDs_D4_Port, LEDs_D4_Pin, &stcGpioCfg);
	Gpio_SetIO(LEDs_D4_Port, LEDs_D4_Pin); 

	Gpio_Init(LEDs_D5_Port, LEDs_D5_Pin, &stcGpioCfg);
	Gpio_SetIO(LEDs_D5_Port, LEDs_D5_Pin); 
	
}

